package com.cassio.guarapari.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@NamedQueries({ 
	@NamedQuery(name = "findAllActives", query = "select l from Locacao l") 
})
public class Locacao implements Serializable {
	private static final long serialVersionUID = 7185979629577547758L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;
	
	@Temporal(TemporalType.DATE)
	@Column(nullable = false)
	private Date inicio;
	
	@Temporal(TemporalType.DATE)
	@Column(nullable = false)
	private Date fim;
	
	//Pagamento
	private Double valorNegociado;
	@Temporal(TemporalType.DATE)
	private Calendar dataReserva;
	private Double valorReserva;
	@Temporal(TemporalType.DATE)
	private Calendar dataPagamento;
	private Double valorPago;
	
	private String comentario;
	
	@ManyToOne
	private Imovel imovel;
	
	@ManyToOne(cascade=CascadeType.PERSIST)
	private Inquilino responsavel;
	
	@ManyToMany(cascade=CascadeType.PERSIST)
	private List<Inquilino> inquilinos;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Date getInicio() {
		return inicio;
	}

	public void setInicio(Date inicio) {
		this.inicio = inicio;
	}

	public Date getFim() {
		return fim;
	}

	public void setFim(Date fim) {
		this.fim = fim;
	}

	public Double getValorNegociado() {
		return valorNegociado;
	}

	public void setValorNegociado(Double valorNegociado) {
		this.valorNegociado = valorNegociado;
	}

	public Calendar getDataReserva() {
		return dataReserva;
	}

	public void setDataReserva(Calendar dataReserva) {
		this.dataReserva = dataReserva;
	}

	public Double getValorReserva() {
		return valorReserva;
	}

	public void setValorReserva(Double valorReserva) {
		this.valorReserva = valorReserva;
	}

	public Calendar getDataPagamento() {
		return dataPagamento;
	}

	public void setDataPagamento(Calendar dataPagamento) {
		this.dataPagamento = dataPagamento;
	}

	public Double getValorPago() {
		return valorPago;
	}

	public void setValorPago(Double valorPago) {
		this.valorPago = valorPago;
	}

	public String getComentario() {
		return comentario;
	}

	public void setComentario(String comentario) {
		this.comentario = comentario;
	}

	public Imovel getImovel() {
		return imovel;
	}

	public void setImovel(Imovel imovel) {
		this.imovel = imovel;
	}

	public Inquilino getResponsavel() {
		return responsavel;
	}

	public void setResponsavel(Inquilino responsavel) {
		this.responsavel = responsavel;
	}

	public List<Inquilino> getInquilinos() {
		return inquilinos == null ? new ArrayList<Inquilino>() : inquilinos;
	}
}
